var address={
	"E1":[{"val":"B01","name":"海淀区"},{"val":"B02","name":"大兴区"},{"val":"B03","name":"昌平区"},{"val":"B04","name":"朝阳区"},{"val":"B05","name":"房山区"},{"val":"B06","name":"顺义区"},],
	"E2":[{"val":"B11","name":"和平区"},{"val":"B12","name":"河东区"},{"val":"B13","name":"河西区"},{"val":"B14","name":"南开区"},{"val":"B15","name":"河北区"},{"val":"B16","name":"红桥区"},],
	"E3":[{"val":"B21","name":"石家庄"},{"val":"B22","name":"唐山"},{"val":"B23","name":"秦皇岛"},{"val":"B24","name":"邯郸"},{"val":"B25","name":"邢台"},{"val":"B26","name":"保定"},],
	"E4":[{"val":"B31","name":"郑州"},{"val":"B32","name":"开封"},{"val":"B33","name":"洛阳"},{"val":"B34","name":"商丘"},{"val":"B35","name":"濮阳"},{"val":"B36","name":"鹤壁"},],
	"E5":[{"val":"B41","name":"太原"},{"val":"B42","name":"大同"},{"val":"B43","name":"阳泉"},{"val":"B44","name":"长治"},{"val":"B45","name":"晋城"},{"val":"B46","name":"运城"},],
	"E6":[{"val":"B51","name":"济南"},{"val":"B52","name":"青岛"},{"val":"B53","name":"枣庄"},{"val":"B54","name":"东营"},{"val":"B55","name":"烟台"},{"val":"B56","name":"潍坊"},],
}

$(function() {
	$("#province").on("change", SelectChange);
	$(".confirm").click(jumpIndex);
});

function SelectChange() {
	var city = address[$(this).val()];
	$("#city").empty();
	for (var i = 0; i < city.length; i++) {
		$("<option></option>").val(city[i]["val"]).text(city[i]["name"]).appendTo($("#city"));
	}
}

function jumpIndex(){
	var province = $("#province").find("option:selected").text();
	var city = $("#city").find("option:selected").text();
	var street = $("input[name='txtStreet']").val();
	var number = $("input[name='txtHouseNumber']").val();
	var address = "?province=" + province + "&city=" + city;
	if(street != ""){
		address += "&street=" + street;
	}
	if(number != ""){
		address += "&number=" + number;
	}
	window.location="Buy.html" + address;
}